#include "ProgramSelector.h"
 

ProgramSelector::ProgramSelector(void){
  halOutput = HalObjects::getHalOutput();
  halInput = HalObjects::getHalInput();
  state = 0;
}

int ProgramSelector::Start(void){
  halInput->clearChange();
  halInput->update();
  halOutput->toggle_program_leds(state+1);
  bool i = true;
  while(i){
    halInput->update();
    if(halInput->readProgram()){
      if(state < 2){
        state ++;
      }else{
        state = 0;
      }
      halOutput->toggle_program_leds(state+1);
    }
    if(halInput->readStart()){
      halOutput->toggle_program_leds(3);
      i = false;
    }
  }
  Serial.println(state+1);
  return state+1;
}
